<?php
	$id = $_GET['id'];
?>
<div class="judul_content">Data Stok</div>

<form method="post" action="utama.php?module=mod_anime">
	<table class="tbl_cari">
		<tr>
			<td width="65"></td>
			<td width="200"></td>
			<td></td>
			<td></td>
			<td align="right"><a href="utama.php?module=mod_stok&view=form_tambah&id=<?php echo $id; ?>"> <input type="button" value="Tambah Data" class="tambah"></a></td>
		</tr>
	</table>
</form>

<table class="table" border="1">
    <tr>
        <th width="20">No</th>
        <th>Ukuran</th>
		<th>Stok</th>
        <th width="50">Aksi</th>
    </tr>
    <?php
    	$p= new paging ;
		$batas= 10;

		//cek halaman dan posisi halaman
		$posisi = $p ->cariposisi($batas) ;

    	$sttmt = $koneksi->query("select * from stok s inner join ukuran u on s.id_ukuran = u.id_ukuran where id_produk=$id limit $posisi,$batas");
    	$no = $posisi + 1;

		while($hasil = $sttmt->fetch(PDO::FETCH_ASSOC)){
    		?>
		    <tr>
		        <td><?php echo $no; ?></td>
		        <td><?php echo $hasil[ukuran]; ?></td>
				<td><?php echo $hasil[stok]; ?></td>
		        <td>
		        	<a href="utama.php?module=mod_stok&view=form_edit&id=<?php echo $hasil[id_stok]; ?>">
						<img src="asset/images/edit.png" title="Edit">
					</a>
		        	<a href="utama.php?module=mod_stok&act=hapus&id=<?php echo $hasil[id_stok]; ?>" onclick="return confirm('Anda yakin ingin Menghapus Data ?')">
		        		<img src="asset/images/delete.png" title="Hapus">
		        	</a>
		        </td>
		    </tr>
    		<?php
    		$no++;
		}
	?>
</table>
<br>
<?php
	$sttmt = $koneksi->query("select * from stok where id_produk = $id order by id_stok desc");
	$jumlah_data = $sttmt->rowCount();
	//dapatkan jumlah halaman
	$jumlah_halaman= $p->jumlahhalaman($jumlah_data,$batas);
	//cetak link
	$linkhalaman=$p->navhalaman($_GET['halaman'],$jumlah_halaman,$_SERVER['PHP_SELF']."?module=mod_stok");
	print($linkhalaman);
?>
        